package com.museum.demo.Interface;

import lombok.Data;

import java.io.Serializable;

/*name: 接口抽象类
* function: 定义返回内容和形式
* detail: 与服务器交互的过程中经常会出现不同的错误，
* 需要精准的发现错误返回给前端。
* 1.
* */

@Data
public class Result implements Serializable {
    private Integer code;
    private String message;
    private Object data;

    public Result(){

    }

    public static Result Success(){
        Result result = new Result();
        result.setCode(ResultCode.SUCCESS.getCode());
        result.setMessage(ResultCode.SUCCESS.getMessage());
        return result;
    }

    public static Result Success(Object data){
        Result result = new Result();
        result.setCode(ResultCode.SUCCESS.getCode());
        result.setMessage(ResultCode.SUCCESS.getMessage());
        result.setData(data);
        return result;
    }

    public static Result Search_Fail(){
        Result result = new Result();
        result.setCode(ResultCode.NULL_RESULT.getCode());
        result.setMessage(ResultCode.NULL_RESULT.getMessage());

        return result;
    }

    public static Result Login_Fail(){
        Result result = new Result();
        result.setCode(ResultCode.CAR_NULL.getCode());
        result.setMessage(ResultCode.CAR_NULL.getMessage());

        return result;

    }

    public static Result Param_Null(){
        Result result = new Result();
        result.setCode(ResultCode.PARAM_NULL.getCode());
        result.setMessage(ResultCode.PARAM_NULL.getMessage());

        return result;
    }

    public static Result Param_null(String WhereParam){
        Result result = new Result();
        result.setCode(ResultCode.PARAM_NULL.getCode());
        result.setMessage(ResultCode.PARAM_NULL.getMessage());
        result.setData(WhereParam+"，此处参数为空");

        return result;
    }
}
